package ao.ai.ml.algo.supervised.model.validation.impl;

import ao.ai.ml.algo.supervised.model.algo.plain.SupervisedPlainLearner;
import ao.ai.ml.algo.supervised.model.example.Example;
import ao.ai.ml.algo.supervised.model.validation.ext.BinaryValidation;
import ao.ai.ml.model.feature_set.FeatureList;
import ao.ai.ml.model.feature_set.ext.cat.bin.SingleBinaryFeature;
import ao.ai.ml.model.fitness.FitnessMeasure;
import ao.ai.ml.model.fitness.impl.MisclassError;
import ao.ai.ml.model.value.FeatureValue;

import java.util.Collection;

/**
 * User: aostrovsky
 * Date: 1-Feb-2010
 * Time: 10:59:27 AM
 */
public class RandomBinaryValidation
            <I extends FeatureList<? extends FeatureValue>>
        implements BinaryValidation<I>
{
    //--------------------------------------------------------------------
    private final RandomSampleValidation<
                    I, SingleBinaryFeature> delegate;


    //--------------------------------------------------------------------
    public RandomBinaryValidation(
            int nSamples, double testingFraction)
    {
        delegate = new RandomSampleValidation<
                        I, SingleBinaryFeature>(
                MisclassError.factory(),
                nSamples, testingFraction);
    }


    //--------------------------------------------------------------------
    @Override
    public <II extends I, OO extends SingleBinaryFeature>
                FitnessMeasure
            validate(SupervisedPlainLearner<II, OO> learner,
                     Collection<? extends Example<II, OO>> data)
    {
        return delegate.validate(learner, data);
    }
}